<#assign ctx="${rc.contextPath}">
<html>
<head>
    <title>转换工具</title>
    <script type="text/javascript" src="${ctx}/static/js/base64.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/md5.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/sha1.js"></script>
    <script type="text/javascript">
        function timestampTrans() {
            var timeTrans1 = $("#timeTrans1").val();
            if("" != timeTrans1){
                var date = new Date();
                date.setFullYear(timeTrans1.substring(0, 4));
                date.setMonth(timeTrans1.substring(5, 7) - 1);
                date.setDate(timeTrans1.substring(8, 10));
                date.setHours(timeTrans1.substring(11, 13));
                date.setMinutes(timeTrans1.substring(14, 16));
                date.setSeconds(timeTrans1.substring(17, 19));
                var timeTrans2 = date.getTime();
                $("#timeTrans2").val(timeTrans2);
            }
        }

        function dateTrans(){
            var timeTrans3 = $("#timeTrans3").val();
            var timeTrans4 = new Date(parseInt(timeTrans3)).toLocaleString().replace(/\//g,"-").replace("上午","");
            $("#timeTrans4").val(timeTrans4);
        }

        function enURI() {
            var codeTrans1 = $("#codeTrans1").val();
            $("#codeTrans2").val(encodeURI(codeTrans1));
        }

        function deURI() {
            var codeTrans3 = $("#codeTrans3").val();
            $("#codeTrans4").val(decodeURI(codeTrans3));
        }

        function esc() {
            var codeTrans5 = $("#codeTrans5").val();
            $("#codeTrans6").val(escape(codeTrans5));
        }

        function unesc() {
            var codeTrans7 = $("#codeTrans7").val();
            $("#codeTrans8").val(unescape(codeTrans7));
        }

        function encode5(){
            var md51 = $("#md51").val();
            $("#md52").val(hex_md5(md51));
        }

        function encode1(){
            var sha11 = $("#sha11").val();
            $("#sha12").val(hex_sha1(sha11));
        }

        function encode64(){
            var base = new Base64();
            var base641 = $("#base641").val();
            $("#base642").val(base.encode(base641));
        }

        function decode64(){
            var base = new Base64();
            var base643 = $("#base643").val();
            $("#base644").val(base.decode(base643));
        }
    </script>
</head>

<body>
<div class="breadcrumb">开发工具 > 转换工具</div>

<form class="form-horizontal form-edit" id="frmEdit">
    <fieldset class="dg-fieldset">
        <legend>时间转换</legend>
        <div class="form-item">
            <div class="form-lab">时间转时间戳：</div>
            <div class="form-field">
                <input class="text" type="text" id="timeTrans1" placeholder="2011-11-11 11:11:11"/>
                <input class="btn btn-primary" type="button" onclick="timestampTrans()" value="转换"/>
                <input class="text" type="text" id="timeTrans2" placeholder="1320981071997"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">时间戳转时间：</div>
            <div class="form-field">
                <input class="text" type="text" id="timeTrans3" placeholder="1320981071997"/>
                <input class="btn btn-primary" type="button" onclick="dateTrans()" value="转换"/>
                <input class="text" type="text" id="timeTrans4" placeholder="2011-11-11 11:11:11"/>
            </div>
        </div>
    </fieldset>

    <fieldset class="dg-fieldset">
        <legend>编码转换</legend>
        <div class="form-item">
            <div class="form-lab">encodeURI：</div>
            <div class="form-field">
                <input class="text" type="text" id="codeTrans1"/>
                <input class="btn btn-primary" type="button" onclick="enURI()" value="转换"/>
                <input class="text" type="text" id="codeTrans2"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">decodeURI：</div>
            <div class="form-field">
                <input class="text" type="text" id="codeTrans3"/>
                <input class="btn btn-primary" type="button" onclick="deURI()" value="转换"/>
                <input class="text" type="text" id="codeTrans4"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">escape：</div>
            <div class="form-field">
                <input class="text" type="text" id="codeTrans5"/>
                <input class="btn btn-primary" type="button" onclick="esc()" value="转换"/>
                <input class="text" type="text" id="codeTrans6"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">unescape：</div>
            <div class="form-field">
                <input class="text" type="text" id="codeTrans7"/>
                <input class="btn btn-primary" type="button" onclick="unesc()" value="转换"/>
                <input class="text" type="text" id="codeTrans8"/>
            </div>
        </div>
    </fieldset>

    <fieldset class="dg-fieldset">
        <legend>加密解密</legend>
        <div class="form-item">
            <div class="form-lab">MD5加密：</div>
            <div class="form-field">
                <input class="text" type="text" id="md51"/>
                <input class="btn btn-primary" type="button" onclick="encode5()" value="加密"/>
                <input class="text" type="text" id="md52"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">SHA1加密：</div>
            <div class="form-field">
                <input class="text" type="text" id="sha11"/>
                <input class="btn btn-primary" type="button" onclick="encode1()" value="加密"/>
                <input class="text" type="text" id="sha12"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">BASE64加密：</div>
            <div class="form-field">
                <input class="text" type="text" id="base641"/>
                <input class="btn btn-primary" type="button" onclick="encode64()" value="加密"/>
                <input class="text" type="text" id="base642"/>
            </div>
        </div>
        <div class="form-item">
            <div class="form-lab">BASE64解密：</div>
            <div class="form-field">
                <input class="text" type="text" id="base643"/>
                <input class="btn btn-primary" type="button" onclick="decode64()" value="解密"/>
                <input class="text" type="text" id="base644"/>
            </div>
        </div>
    </fieldset>
</form>
</body>
</html>
